<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Incident
 *
 * @author Quentin
 */
class Incident implements JsonSerializable{
    private $machine = null;
    private $id = -1;
    private $date = null;
    private $type = null;
    private $content = null;
    private $resolve = null;
    public function __construct($machine, $date, $type, $content = null, $resolve = null){
        $this->machine = $machine;
        $this->date = $date;
        $this->type = $type;
        $this->content = $content;
        $this->resolve = $resolve;
    }
    public function __toString(){
        return "Incident[machine='$this->machine', type='$this->type']";
    }
    public function getId(){
        return $this->id;
    }
    public function setId($id){
        $this->id = $id;
    }
    public function getMachine(){
        return $this->machine;
    }
    public function setMachine($machine){
        $this->machine = $machine;
    }
    public function getDate(){
        return $this->date;
    }
    public function setDate($date){
        $this->date = $date;
    }
    public function getType(){
        return $this->type;
    }
    public function setType($type){
        $this->type = $type;
    }
    public function getContent(){
        return $this->content;
    }
    public function setContent($content){
        $this->content = $content;
    }
    public function getResolve(){
        return $this->resolve;
    }
    public function setResolve($resolve){
        $this->resolve = $resolve;
    }
    public function jsonSerialize() {
        $json = Array();
        $json["id"] = $this->id;
        $json["machine"] = $this->machine;
        $json["type"] = $this->type;
        $json["date"] = $this->date;
        $json["content"] = $this->content;
        $json["resolve"] = $this->resolve;
        return $json;
    }
    public function xmlSerialize($domtree){
        $xmlRoot = $domtree->createElement("incident");
        $id = $domtree->createElement("id", $this->id);
        $xmlRoot->appendChild($id);
        
        $xmlRoot->appendChild($this->machine->xmlSerialize($domtree));
        $type = $domtree->createElement("type", $this->type);
        $xmlRoot->appendChild($type);
        $date = $domtree->createElement("date", $this->date);
        $xmlRoot->appendChild($date);
        $content = $domtree->createElement("content", $this->content);
        $xmlRoot->appendChild($content);
        $resolve = $domtree->createElement("resolve", $this->resolve);
        $xmlRoot->appendChild($resolve);
        return $xmlRoot;
    }
}

?>
